/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.hamacekj.geometr;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;

/**
 * Nástroj k tisknutí nákresů.
 * @author hamacekh
 */
public class PrintSteps implements Printable {

    private ConstructionPainter painter;

    public PrintSteps(ConstructionPainter painter) {
        this.painter = painter;
    }
    
    @Override
    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
        if(pageIndex > 0){
            return NO_SUCH_PAGE;
        }
        Graphics2D g = (Graphics2D)graphics;
        g.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
        painter.paint(g, null, (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight());
        return PAGE_EXISTS;
    }
    
}
